<template>
  <div class="mb20">
    <el-date-picker
      v-model="time"
      type="daterange"
      range-separator="至"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
      value-format="YYYY-MM-DD"
      :clearable="false"
    />
    <el-button
      type="primary"
      class="ml20"
      @click="handleSearch"
    >
      查询
    </el-button>
    <el-button @click="handleReset">
      重置
    </el-button>
  </div>
  <TableCharts />
  <PieCharts />
</template>

<script setup>
import TableCharts from './components/TableCharts.vue'
import PieCharts from './components/PieCharts.vue'
import { provide, ref } from 'vue'
import { ElMessage } from 'element-plus'

const time = ref([])
const timeRange = ref([])
const handleSearch = () => {
  if (time.value.length === 0) {
    ElMessage({
      message: '请选择时间范围',
      type: 'error',
      duration: 1000
    })
    return
  }
  timeRange.value = time.value
}

const handleReset = () => {
  time.value = []
  timeRange.value = []
}
provide('timeRange', { timeRange })
</script>

<style lang="scss" scoped>
.panel-group {
  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

</style>
